%{
#include <stdio.h>
#include "y.tab.h"  
%}

%%

int     {return INT;}
unsigned {return UNSIGNED;}
typedef {return TYPEDEF;}
struct  {return STRUCT;}
double  {return DOUBLE;}
long    {return LONG;}
const   {return CONST;}
char    {return CHAR;}
float   {return FLOAT;}
void    {return VOID;}
\*      {return STAR;}
\*\*    {return DSTAR;}
\{      {return LB;}
\}      {return RB;}
\(      {return LP;}
\)      {return RP;}
\[      {return LSB;}
\]      {return RSB;}
\/      {return SLASH;}
\\      {return BACKSLASH;}
\;      {return SEMICOLON;}
\,      {return COMMA;}

[ \t\n]+   ;
[a-zA-Z0-9_-]+  {yylval.string = strdup(yytext); return WORD;}

%%

// very important
// yylval.string is from e2.y see the %union define #include the e2.y
void yyerror(char *s) {
    fprintf(stderr, "%s\n", s);
}
